package com.kaifamiao.N0727;

public class Person1 {

    private String name;
    private int age;
    private String gender;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0 || age > 150) {
            System.out.println("输出错误，年龄"+age+"不合法，请重新输入");
            return;
        }
        this.age = age;
    }

    public String getGender(){
        return gender;
    }

    public void setGender(String gender){
        if("男".equals(gender)||"女".equals(gender)){
            this.gender = gender;
        }else{
            System.out.println("性别不合法");
        }
    }

    public Person1(String name,int age,String gender){
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public Person1(){
        this.name = "无名氏";
        this.age = 18;
        this.gender = "男";
    }

    public void say(){
        System.out.println("自我介绍一下，姓名："+this.name+"\t性别："+this.gender+"\t年龄："+this.age);
    }

    public static void main(String[]args){
        Person1 person = new Person1();
        person.setName("李逵");
        person.setGender("男");
        person.setAge(20);
        person.say();
    }
}
